package com.xmwzw.catpu.validator;

/**
 * Created by chenpeiqiang on 2017/11/28.
 */

public class RangeValidator extends Validator {

    /**
     * The start of the range
     */
    final int START_RANGE;

    /**
     * The end of the range
     */
    final int END_RANGE;

    public RangeValidator(String errorMessageString, int start, int end) {
        super(errorMessageString);
        START_RANGE = start;
        END_RANGE = end;
    }

    @Override
    public boolean isValid(String value) {
        if (value != null && value.length() > 0) {
            int inputedSize = value.length();
            return inputedSize >= START_RANGE
                    && inputedSize <= END_RANGE;
        } else
            return false;
    }
}
